/*
 * main.cpp
 *
 *  Created on: 12.02.2013
 *      Author: Roma Jam
 */

#include "main.h"
#include "math.h"
#include "stdio.h"
#include "stdlib.h"


#define MEAN    0.0
#define STDEV   0.95

dist_t Data;

FILE *TxtFile;
int main(void) {

    TxtFile = fopen("Dist.txt", "wt");

    for(int i=0; i<=SIZE_OF_BUF; i++){
        Data.Norm[i] = MEAN + ((double)rand() / RAND_MAX);
        Data.Gauss[i] = MEAN + ((double)rand() / RAND_MAX);
        Data.Reley[i] = MEAN + ((double)rand() / RAND_MAX);

        Data.Logm[i] = STDEV * sqrt(-2.0 * log(Data.Gauss[i]));

        Data.Gauss[i] = Data.Logm[i] * cos(2 * M_PI * Data.Norm[i]) + MEAN;

        Data.Reley[i] = Data.Logm[i] * cos(2 * M_PI * Data.Reley[i]) + 1;
        Data.Reley[i] = sqrt((Data.Gauss[i] * Data.Gauss[i]) + (Data.Reley[i] * Data.Reley[i]));


        fprintf(TxtFile, "%lf %lf %lf %lf %lf\n",
                Data.Norm[i],
                Data.Gauss[i],
                Data.Logm[i],
                Data.Reley[i],
                Data.Rayes[i]
        );
    }

    fclose(TxtFile);
    printf("Completed\n");
    return 0;
}
